package edu.fudan.jwxt.dto;

import cn.hutool.core.bean.BeanUtil;
import edu.fudan.jwxt.entity.User;
import lombok.Data;


import java.util.ArrayList;
import java.util.List;

@Data
public class PersonInfo {
    private String uid;
    private String name;
    private String email;
    private String phone;
    private String IdentityId;
    private String role;
    private String status;
    private int collegeId;
    private int majorId;
    private String collegeName;
    private String majorName;

//    private List<Course> courses;
//    private List<Exam> exams;

    public static PersonInfo getPersonIfo(User user){
        PersonInfo personInfo = new PersonInfo();
        BeanUtil.copyProperties(user,personInfo,true);
        return personInfo;
    }

    public static List<PersonInfo> toPersonInfoList(List<User> users){
        List<PersonInfo> personInfoList = new ArrayList<>();
        for (User user : users) {
            PersonInfo pi = PersonInfo.getPersonIfo(user);
            personInfoList.add(pi);
        }

        return  personInfoList;
    }
}
